//
//  WHTabBarController.m
//  WHEasyBizLink
//
//  Created by shengmeng chen on 2024/11/23.
//

#import "WHTabBarController.h"

#import "WHNavigationController.h"
#import "WHMyCenterVC.h"
#import "WHEnterpriseCompanyVC.h"
#import "WHEnterpriseGovernmentVC.h"
#import "WHLoginViewController.h"

@interface WHTabBarController ()

@end

@implementation WHTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initTabbarItem];
}

-(void)initTabbarItem
{
    WHEnterpriseCompanyVC  *vc= [[WHEnterpriseCompanyVC alloc]init];
    [self controller:vc title:@"企业" image:@"enterprise_default" selectedimage:@"enterprise_select" isAdd:YES];
    
    
//    WHEnterpriseGovernmentVC  *gvc= [[WHEnterpriseGovernmentVC alloc]init];
//    [self controller:gvc title:@"政府" image:@"PProof_def" selectedimage:@"PProof_sel" isAdd:YES];
    
    WHMyCenterVC  *meVC= [[WHMyCenterVC alloc]init];
    [self controller:meVC title:@"我的" image:@"my_default" selectedimage:@"my_select" isAdd:YES];
    
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:RGBColor(55, 143, 206),NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
    
    if([[UIDevice currentDevice].systemVersion doubleValue]>=13.0)
       {
          [[UITabBar appearance] setUnselectedItemTintColor:[UIColor grayColor]];
          [UITabBar appearance].tintColor = RGBColor(55, 143, 206);
       }
    
    if (@available(iOS 13.0, *)) {
            UITabBarAppearance * appearance = [[UITabBarAppearance alloc] init];
             // 背景色
            appearance.backgroundColor = [UIColor whiteColor];
            self.tabBar.standardAppearance = appearance;
            if (@available(iOS 15.0, *)) {
                self.tabBar.scrollEdgeAppearance = appearance;
            }
        }
}

//初始化一个zi控制器
-(void)controller:(UIViewController *)TS title:(NSString *)title image:(NSString *)image selectedimage:(NSString *)selectedimage isAdd:(BOOL)isAdd
{
    TS.tabBarItem.title = title;
    TS.tabBarItem.image = [UIImage imageNamed:image];
    TS.tabBarItem.selectedImage = [[UIImage imageNamed:selectedimage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    WHNavigationController *nav = [[WHNavigationController alloc]initWithRootViewController:TS];
    if(isAdd)
    {
      [self addChildViewController:nav];
    }
    //设置导航的背景
//    nav.navigationBar.translucent =YES;
//    //设置导航的和状态栏
//    nav.navigationBar.barTintColor = RGBColor(246,246,246);// RGBColor(0, 153,170);
//    //设置返回颜色为黑色
//    nav.navigationBar.tintColor = [UIColor blackColor];
//    //设置字体为白色
//    nav.navigationBar.barStyle  = UIBarStyleBlack;
//    //设置导航字体大小和颜色
////    UIFont *font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
////    [nav.navigationBar setTitleTextAttributes:
////     @{NSFontAttributeName:font,
////    NSForegroundColorAttributeName:[UIColor blackColor]}];
    
//    nav.nDelegate = TS;

//    if (@available(iOS 15.0, *))
//    {
//        UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
//        appearance.backgroundColor =RGBColor(134,190,250);// RGBColor(12,87,211); //[UIColor systemGroupedBackgroundColor];
//        appearance.shadowColor     = [UIColor clearColor];
//        nav.navigationBar.standardAppearance   = appearance;
//        nav.navigationBar.scrollEdgeAppearance = appearance;
//       }
    //隐藏导航左侧的字体
    //[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-300,0) forBarMetrics:UIBarMetricsDefault];
    
}


@end
